package chapter1.No1_3_currentThread方法;

/**
 * 1. 通过A,B情况深刻理解Thread.currentThread.getName()和this.getName()
 *
 * @author liujian
 * @version 2016/11/8 0008
 */
public class MyThread extends Thread {
    public MyThread() {
        System.out.println("构造方法运行开始");
        System.out.println("Thread.currentThread().getName()="+Thread.currentThread().getName());
        System.out.println("this.getName()="+this.getName());
        System.out.println("构造方法运行结束");
        System.out.println("=====================================");
    }

    @Override
    public void run() {
        System.out.println("run方法运行开始");
        System.out.println("Thread.currentThread().getName()="+Thread.currentThread().getName());
        System.out.println("this.getName()="+this.getName());
        System.out.println("run方法运行结束");
    }

    public static void main(String[] args) {
        // A 情况
        MyThread myThread = new MyThread();
        Thread m1 = new Thread(myThread, "A");
        m1.start();

//        // B 情况
//        chapter1.MyThread myThread = new chapter1.MyThread();
//        myThread.setName("A");
//        myThread.start();
    }
}
